package com.huang.service.impl;

import com.huang.dao.ChildrenDao;
import com.huang.domain.Children;
import com.huang.domain.ChildrenExample;
import com.huang.service.ChildrenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ChildrenServiceImpl implements ChildrenService {
    @Autowired
    private ChildrenDao childrenDao;

    @Override
    public void add(List<Children> list) {
        for (Children c : list
        ) {
            childrenDao.insert(c);
        }
    }

    @Override
    public List<Children> findAll() {
        ChildrenExample childrenExample = new ChildrenExample();
        childrenExample.createCriteria().andIdIsNotNull();
        return childrenDao.selectByExample(childrenExample);
    }

    @Override
    public void update(List<Children> list) {
        for (Children c : list
        ) {
            childrenDao.updateByPrimaryKey(c);
        }

    }

    @Override
    public boolean isNotNull() {
        return childrenDao.selectByPrimaryKey(1) != null;
    }
}
